#include <iostream>
#include <string.h>

#include "client.h"
#include "login.h"

int main(int argc, char* argv[])
{
      
#define CHECK_ARGC if (i >= argc-1) { \
    fprintf(stderr, "not enough arguments for: %s\n", argv[i]); \
    exit(1); \
}

    std::string addr("127.0.0.1");
    uint16_t port(1717);
    for (int i = 1; i < argc; i++)
    {
        if (!strcmp("-addr", argv[i]))
        {
            CHECK_ARGC
            addr = std::string(argv[++i]);
        }
        if (!strcmp("-port", argv[i]))
        {
            CHECK_ARGC
            port = atoi(argv[++i]);
        }
    }

    Client m_client(addr, port);
    m_client.run();
    LoginUI m_login(addr, port);
    m_login.run();

    return 0;
}